package com.wootion.cims.module.systemsetting.system.controller;

import com.wootion.cims.module.systemsetting.dictionary.model.LogAnotion;
import com.wootion.cims.module.systemsetting.system.dto.SysInformationDto;
import com.wootion.cims.module.systemsetting.system.model.SysInformation;
import com.wootion.cims.module.systemsetting.system.service.SysInformationService;
import com.wootion.cims.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.sql.SQLException;


/**
 * @Author: LanQiang
 * @Date: 2022/11/23/11:22
 * @Description: 作用xxx
 */
@Slf4j
@RestController
@RequestMapping(path = {"/information"})
@Api(value = "系统信息")
public class SysInformationController {
    @Resource
    private SysInformationService sysInformationService;
    
    /**
     * 保存自定义设置
     */
    @ApiOperation(value = "系统信息-保存自定义设置", httpMethod = "POST")
    @PostMapping(path = {"/save"})
    @RequiresAuthentication
    public ResponseResult save(HttpServletRequest request, SysInformationDto sysInformationDto) throws SQLException, IOException {
        log.info("接收到的是{}",sysInformationDto);
        return sysInformationService.saveSysInformation(request,sysInformationDto);
    }

    /**
     * 返回给前端系统信息设置
     */
    @ApiOperation(value = "返回系统默认/用户设置的系统信息", httpMethod = "POST")
    @PostMapping(path = {"/topic"})
    public ResponseResult findTopic(){
        return sysInformationService.findTopicSysInformation();
    }

    /**
     * 获取默认/自定义设置
     * @return
     */
    @ApiOperation(value = "获取默认/自定义封面", httpMethod = "POST")
    @PostMapping(path = {"/default"})
    @RequiresAuthentication
    public ResponseResult findTopicDefaultImageSysInformation(@RequestBody SysInformation sysInformation){
        return sysInformationService.findTopicDefaultImageSysInformation(sysInformation);
    }

}
